<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PHP1611后台用户单页管理</title>
    <meta name="keywords" content="PHP1611后台用户单页管理">
    <meta name="description" content="PHP1611后台用户单页管理">
    <link rel="shortcut icon" href="/Public/Admin/favicon.ico">
    <link rel="shortcut icon" href="favicon.ico">
    <link href="/Public/Admin/css/bootstrap.min.css" rel="stylesheet">
    <link href="/Public/Admin/css/font-awesome.min.css" rel="stylesheet">
    <link href="/Public/Admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/Public/Admin/css/animate.css" rel="stylesheet">
    <link href="/Public/Admin/css/style.css" rel="stylesheet">
    <link href="/Public/Admin/js/plugins/layer/skin/layer.css" rel="stylesheet">
    <link href="/Public/Admin/css/plugins/switchery/switchery.min.css" rel="stylesheet">
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>PHP1611后台用户单页管理</h5>
                </div>
                <div class="ibox-content">
                    <form method="post" class="form-horizontal" action="<?php echo U('page/save');?>" id="forma" name="forma" enctype="multipart/form-data">
                        <input type="hidden" name="id" value="<?php echo ($list["id"]); ?>" />
                        <div class="form-group">
                            <label class="col-sm-2 control-label ">单页名称</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="title" id="title" value="<?php echo ($list["title"]); ?>" >
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">英文名称</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="name" id="name" value="<?php echo ($list["name"]); ?>" >
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">外链接</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="link" id="link" value="<?php echo ($list["link"]); ?>" >
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">关键词</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="keyword" id="keyword" value="<?php echo ($list["keyword"]); ?>" >
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">描述</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="description" id="description" value="<?php echo ($list["description"]); ?>" >
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">内容</label>
                            <div class="col-sm-10">
                                <script type="text/plain" name="content" id="content"><?php echo (strip_tags(htmlspecialchars_decode($list["content"]))); ?></script>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">排序</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="sort" id="sort" value="<?php echo ($list["description"]); ?>" >
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit" id="submit">保存内容</button>
                                <button class="btn btn-white" type="reset" onclick="history.go(-1)">取消</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 配置文件 -->
<script type="text/javascript" src="/Public/Admin/uedit/ueditor.config.js"></script>
<script type="text/javascript" src="/Public/Admin/uedit/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    var ue = UE.getEditor('content');
</script>
<script src="/Public/Admin/js/jquery.min.js"></script>
<script src="/Public/Admin/js/bootstrap.min.js"></script>
<script src="/Public/Admin/js/plugins/layer/layer.js"></script>
<script src="/Public/Admin/js/plugins/switchery/switchery.min.js"></script>
<script src="/Public/Admin/js/plugins/validate/jquery.validate.min.js"></script>
<script src="/Public/Admin/js/plugins/validate/messages_zh.min.js"></script>
<script src="/Public/Admin/js/comment.js"></script>
<script>
    $(function(){
        $.validator.addMethod("checkname",function(value,element,params){
            if(/^[a-zA-Z0-9]{3,16}$/.test(value)) {
                return true;
            }else{
                return false;
            }
        },"");


        $("#forma").validate({
            rules:{
                title:"required",
                name:"required"
            },
            messages:{
                title:'单页名称不能为空!',
                name:'英文名不能为空'

            },
            submitHandler: function (form) {
                /* var objNames = $(form).serializeArray();
                 var dataNames = new Object();
                 $.each(objNames,function(key,val){
                 dataNames[val.name] = val.value;
                 });*/
                var forma = new FormData(document.getElementById('forma')); //通过js获取form表单
                // console.log(forma);
                $.ajax({
                    url:$(form).attr('action'),
                    type:'post',
                    dataType:'json',
                    data:forma,
                    cache:false, //无缓存
                    processData:false, //
                    contentType:false,
                    success:function(data){
                        if(data.status > 0){
                            comment.error(data.msg);
                        }else{
                            comment.success(data.msg,"<?php echo U("page/index");?>");
                        }
                    }
                });
            }
        });
    });
    var elem = document.querySelector('.js-switch');
    var switchery = new Switchery(elem,{ });
</script>
</html>